<?php

/**
 * Project: CrazyPoems
 * Author: Alexandru
 * Date: 29/10/2008
 * File: admin.php
 */

// Load default settings.
require('inc/config.php');
require('inc/functions.misc.php');
require('inc/functions.index.php');
require('inc/functions.admin.php');

// Only admin has access.
if ($cookie->admin != 1) { header("Location: index.php"); }

// Delete category.
$delete = isset($_REQUEST['delete']) && strlen($_REQUEST['delete']) > 0 ? $_REQUEST['delete'] : '';
if (strlen($delete) > 0) {
        $q = mysql_query("DELETE FROM " . TABLE_CATEGORIES . " WHERE id = $delete") or die(mysql_error());
        $smarty->assign('deleted', "yes");
}


$smarty->assign('pageTitle', 'Admin page');
$smarty->assign('breadcrumbs', '<a href="index.php">Home</a> &raquo; Admin');
// Categories
$smarty->assign('adminCategories', getCategories(0, true));
// All members e-mails copy & paste for newsletter
$users = getAllMembers();
$all_emails = '';
foreach ($users as $user) {
	$all_emails .= ', '.$user['email'];
}
$smarty->assign('all_emails', substr($all_emails,2));

$smarty->display('admin.tpl');

// End page.
require('inc/end.php');
?>
